package com.tju.eduservice.controller;


import com.tju.Result;
import com.tju.eduservice.entity.subject.OneSubject;
import com.tju.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author gsc
 * @since 2021-11-27
 */
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //课程分类  把文件通过页面传入
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return  Result.ok();
    }
    //查询课程分类
    @GetMapping("getSubject")
    public Result getSubject(){
        //查询所有一级分类

        List<OneSubject> list = subjectService.getAllSubject();

        return Result.ok().data("list",list);
    }




}

